﻿/**
* 一些公共的js
*   by Zjb
*
*/

function iFrameHeight() {
    var ifm = document.getElementById("mainFrame");
    var subWeb = document.frames ? document.frames["mainFrame"].document : ifm.contentDocument;
    if (ifm != null && subWeb != null) {
        ifm.height = subWeb.body.scrollHeight;
        ifm.width = subWeb.body.scrollWidth;
    }
}




/* 遮罩层 */
//functions about mask    by zjb
$.fn.mask = function (label, delay) {
    $(this).each(function () {
        if (delay !== undefined && delay > 0) {
            var element = $(this);
            element.data("_mask_timeout", setTimeout(function () { $.maskElement(element, label) }, delay));
        } else {
            $.maskElement($(this), label);
        }
    });
};
$.fn.unmask = function () {
    $(this).each(function () {        //移除遮罩层相关Div
        $(this).find(".loadmask-msg,.loadmask").remove();
        $(this).removeClass("masked");
        $(this).removeClass("masked-relative");
        $(this).find("select").removeClass("masked-hidden");
    });
};
$.maskElement = function (element, label) {

    if (element.data("_mask_timeout") !== undefined) {
        clearTimeout(element.data("_mask_timeout"));
        element.removeData("_mask_timeout");
    }

    if (element.hasClass("masked")) {
        $.unmaskElement(element);
    }

    //if (element.css("position") == "static") {
    //    element.addClass("masked-relative");
    //}

    element.addClass("masked");

    var maskDiv = $('<div class="loadmask"></div>');

    var wid = $("#content").width;
    $("#loadmask").css("width", function () { return $("#content").width; });
    $("#loadmask").css("height", function () { return $("#content").height; });

    element.append(maskDiv);

    if (label !== undefined) {
        var maskMsgDiv = $('<div class="loadmask-msg" style="display:none;"></div>');
        maskMsgDiv.append('<div>' + label + '</div>');
        element.append(maskMsgDiv);
        maskMsgDiv.show();
    }

};

//functions about mask  by zjb  end 